<template>
	<!-- 日常作业 -->
	<view class="dailyWork">
		<!-- <image src="/static/base.png" mode=""></image> -->
		<swiper v-if="picList.length>0" class="swiper" :circular="circular" :indicator-dots="indicatorDots" :autoplay="autoplay" :interval="interval" :duration="duration" style="height: 500rpx;">
			<swiper-item v-for="(item,index) in picList" :key="index">
				<image :src="item" mode="" style="width: 100%;height: 100%;"></image>
			</swiper-item>
		</swiper>
		<view class="content">
			<view class="content_title">种植及生产过程</view>
			<view class="content_item" v-for="(item,index) in list" :key="index">
				<view class="content_item_left">
					<view class="line" :style="{borderLeft:index==0?'1px solid rgba(255,255,255,0)':''}"></view>
					<view class="dot" :style="{backgroundColor:colorList[index]}"></view>
					<view class="line"></view>
				</view>
				<view class="content_item_right">
					<view class="content_item_right_time">时间：{{item.recordTime}}</view>
					<view class="">农事过程：{{item.recordType}}</view>
					<view class="">负责人：{{item.recordPerson}}</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	// 		 			 生产过程 农事记录
	import {imgUrl,   getRecord} from "../../api/api_test.js"
	export default {
		data() {
			return {
				imgUrl:imgUrl,
				background: ['color1', 'color2', 'color3'],
				circular:true,//衔接滑动
				indicatorDots: true,
				autoplay: true,
				interval: 2000,
				duration: 500,
				list:[
					// {course:'种子品种：蔬菜',time:'种植时间：2022-03-03',principal:'负责人：张三'},
					// {course:'除虫方式：性诱板',time:'种植时间：2022-03-03',principal:'负责人：张三'},
					// {course:'种子品种：蔬菜',time:'种植时间：2022-03-03',principal:'负责人：张三'},
					// {course:'除虫方式：性诱板',time:'种植时间：2022-03-03',principal:'负责人：张三'},
					// {course:'种子品种：蔬菜',time:'种植时间：2022-03-03',principal:'负责人：张三'},
					// {course:'除虫方式：性诱板',time:'种植时间：2022-03-03',principal:'负责人：张三'},
				],
				productId:'',
				recordType:[
					{dictValue:0,dictLabel:'浇水'},
					{dictValue:1,dictLabel:'施肥'},
					{dictValue:2,dictLabel:'打药'},
					{dictValue:3,dictLabel:'除草'},
					{dictValue:4,dictLabel:'播种'},
					{dictValue:5,dictLabel:'采收'},
				],
				picList:[],
				colorList:['#F5D35A','#9AC455','#76B3FC','#FF005D','#F5D35A','#9AC455','#76B3FC','#FF005D','#F5D35A','#9AC455','#76B3FC','#FF005D']
			};
		},
		onLoad(options){
			this.productId = options.productId
			this.getRecord()
		},
		methods:{
			// 农事记录
			getRecord(){
				getRecord({recordProduct:this.productId},res=>{
					console.log("res 农事记录",res)
					if(res.code == 200 && res.data){
						this.list = res.data
						this.list.forEach(val=>{
							this.recordType.forEach(v=>{
								if(val.recordType == v.dictValue){
									val.recordType = v.dictLabel
								}
							})
							if(val.recordPic){
								this.picList.push(this.imgUrl + val.recordPic)
							}
						})
						console.log("this.picList",this.picList)
					}
				})
			},
		}
	}
</script>

<style lang="scss" scoped>
.dailyWork{
	flex: 1;
	background: url(../../static/maizi.png) no-repeat;
	background-size: 100% 100% ;

	.content{
		padding: 20rpx 40rpx;
		box-sizing: border-box;
		.content_title{
			background: #F4C06C;
			color: #fff;
			font-size: 30rpx;
			text-align: center;
			line-height: 80rpx;
			border-radius: 10rpx;
			width: 100%;
			margin-bottom: 40rpx;
		}
		.content_item{
			display: flex;
			padding: 0 40rpx;
			box-sizing: border-box;
			.content_item_left{
				flex: 0 0 80rpx;
				display: flex;
				flex-direction: column;
				justify-content: center;
				align-items: center;
				.dot{
					width: 30rpx;
					height: 30rpx;
					border-radius: 50%;
					background-color: #7F7F7F;
				}
				.line{
					flex: 1;
					border-left: 1px solid #CCCCCC;
				}
			}
			.content_item_right{
				flex: 1;
				border: 1px solid #D7D7D7;
				border-radius: 20rpx;
				margin: 30rpx 0;
				font-size: 28rpx;
				background: #fff;
				overflow: hidden;
				>view{
					line-height: 60rpx;
					padding: 0 20rpx;
					box-sizing: border-box;
					color: #C0C0C0;
				}
				.content_item_right_time{
					background-color: #76B3FC;
					color: #fff;
				}
			}
		}
	}
}
</style>
